<?php

namespace common\models\user;

use Yii;
use common\helpers\ArrayHelper;

/**
 * This is the model class for table "{{%user_signin_log}}".
 *
 * @property int $id
 * @property int $user_id 用户ID
 * @property string|null $date 签到日期
 * @property string|null $location 签到位置信息
 * @property string|null $gis 空间位置信息
 * @property string|null $geohash
 * @property int $ip 签到IP
 * @property int $repaired_at 补签时间
 * @property int $created_at 签到时间
 * @property int $updated_at 签到更新时间
 */
class UserSigninLog extends \common\db\ActiveRecord {

    /**
     * {@inheritdoc}
     */
    public static function tableName() {
        return '{{%user_signin_log}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules() {
        return [
            [['user_id', 'ip', 'repaired_at', 'created_at', 'updated_at'], 'integer'],
            [['date'], 'safe'],
            [['gis'], 'safe'],
            [['location'], 'string', 'max' => 255],
            [['geohash'], 'string', 'max' => 20],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels() {
        return [
            'id' => 'ID',
            'user_id' => '用户ID',
            'date' => '签到日期',
            'location' => '签到位置信息',
            'gis' => '空间位置信息',
            'geohash' => 'Geohash',
            'ip' => '签到IP',
            'repaired_at' => '补签时间',
            'created_at' => '签到时间',
            'updated_at' => '签到更新时间',
        ];
    }

    /**
     * @inheritdoc
     */
    public function fields() {
        return [
            'id',
            'user_id',
            'date',
            'location',
            'status' => function() {
                return $this->date == date('Y-m-d');
            },
        ];
    }

}
